/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.tshirtcannon;

/**
 * The first firing state.
 * @see FiringState
 * @see TShirtCannon
 * @see TShirtCannonState
 */
class FiringState1 extends FiringState {

    protected static final double kFiringTime1 = 3.0; //TODO: adjust value
    private static FiringState1 m_instance = new FiringState1();

    private FiringState1() {
    }

    /**
     * enter is called when the t-shirt cannon enters this state.
     * @param tsc The t-shirt cannon.
     */
    void enter(TShirtCannon tsc) {
        super.enter(tsc);
        tsc.setFireValve1State(true);
        tsc.setFireValve2State(false);
    }

    /**
     * update is called when something calls the t-shirt cannon's update
     * function and this is the current state.
     * @param tsc The t-shirt cannon.
     */
    void update(TShirtCannon tsc) {
        if (tsc.getTimerSeconds() > kFiringTime1) {
            tsc.setFired(1, true);
            if (tsc.isEmpty()) {
                tsc.changeState(DisabledState.instance());
            } else {
                tsc.changeState(PressurizingState.instance());
            }
        }

        super.update(tsc);
    }

    /**
     * exit is called when the t-shirt cannon enters this state.
     * @param tsc The t-shirt cannon.
     */
    void exit(TShirtCannon tsc) {
        super.exit(tsc);
    }

    /**
     * getName is called to get the name of this state.
     * @return The name of this state.
     */
    String getName() {
        return "Firing1";
    }

    /**
     * Returns the instance of this state.
     * @return The instance of this state.
     */
    static FiringState1 instance() {
        return m_instance;
    }
}
